package com.heo.util;

import java.text.DecimalFormat;

public class SystemInfo
{
  static DecimalFormat df = new DecimalFormat(".###M");

  public static String getMaxMemory()
  {
    return df.format(new Float(Runtime.getRuntime().maxMemory()) / 1024 / 1024);
  }

  public static String getFreeMemory()
  {
    return df.format(new Float(Runtime.getRuntime().freeMemory()) / 1024 / 1024);
  }

  public static String getUseMemory()
  {
    return df.format((new Float(Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory())) / 1024 / 1024);
  }

  public static int getThreadCount()
  {
    // 获得线程总数
    return Thread.getAllStackTraces().size();
  }
}
